<div class="gallery">
	<div class="actions">
		<a href="<?=site_url(array('c' => 'cms_gallery', 'm' => 'add_set'))?>" title="Add Image">
			<img src="<?=public_base_url()?>admin/images/function/add.gif" width="106" height="31" border="0">
		</a>
	</div>
	<div class="set-grid">
		<?php if(!empty($set_list)):$i=0?>
		<?php foreach($set_list as $item):?>
		<div class="item" id="mediaset_<?=$item['id']?>">
			<h5><?=$item['title']?></h5>
			<div class="set-case">
				<?php
					$mediaIds = $item['media_ids'];
					$mediaIds = explode(",", $mediaIds);
				?>
				<?php if(intval($item['represent'])):?>
				<img src="<?=site_url(array('c' => 'cms_gallery', 'm' => 'thumbnail', 'image_id' => $item["represent"]))?>" alt="<?=$item['title']?>"/>
				<?php else:?>
				<img src="<?=site_url(array('c' => 'cms_gallery', 'm' => 'thumbnail', 'image_id' => $mediaIds[0]))?>" alt="<?=$item['title']?>"/>
				<?php endif;?>
			</div>
			<div class="desc"><?=count($mediaIds)?> photos | <a href="<?=site_url(array('c' => 'cms_gallery', 'm' => 'edit_set', 'id' => $item['id']));?>">Edit</a>| <a href="<?=site_url(array('c' => 'cms_gallery', 'm' => 'delete_set', 'id' => $item['id']));?>" class="delete">Delete</a></div>
		</div>
		<?php $i++;endforeach;?>
		<div class="clearfix"></div>
		<?php else:?>
		<h3>Please create set for this gallery</h3>
		<?php endif;?>
	</div>
</div>
<div id="dialog-confirm" title="Delete image?" style="display: none;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This image will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<script language="JavaScript" type="text/javascript">
(function($){
	$('a.delete').click(function(){
		var href = $(this).attr("href");
		$("#dialog-confirm").dialog({
			resizable: false,
			height:180,
			modal: true,
			buttons: {
				'Delete': function() {
					jQuery.getJSON(href, {},function(data){
						$("#mediaset_"+data.mediaset_id).remove();
					});
					$(this).dialog('close');
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			}
		});
		return false;
	});
})(jQuery);
</script>